//
//  Param.swift
//  PlayGround
//
//  Created by admin on 2021/9/17.
//

import Foundation
import UIKit


class SettingParam {
    
    var name:String
    var key:String
    var value:Any
    
    init(name:String, key:String, value: Any) {
        self.name = name
        self.key = key
        self.value = value
        inputView.titleLab.text = self.name
    }
    
    lazy var inputView: SettingInputView = {
        switch value.self{
        case  is Int:
            let inputView = IntView()
            return inputView
        case  is Float, is Double:
            let inputView = FloatView()
            return inputView
        case is Date:
            let inputView = DateView()
            return inputView
        case is PushViewController:
            let inputView = PushView()
            inputView.data = self
            return inputView
            
        default:
            return SettingInputView()
        }
       
    }()
}
class SettingInputView: UIView {
    
    var data:SettingParam? = nil{
        didSet{
            updateUI()
        }
    }
    lazy var titleLab: UILabel = {
        let lab = UILabel()
        lab.textColor = .darkText
        lab.font = .systemFont(ofSize: 14)
        return lab
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(titleLab)
    }
    var value:Any{
        return "0"
    }
    func updateUI()  {
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
   
}




